package cn.xopencode.userservice.manager;

import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.userservice.rpc.dept.dto.DeptDTO;
import cn.xopencode.userservice.rpc.user.dto.*;
import cn.xopencode.userservice.service.DeptService;
import cn.xopencode.userservice.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserManager {

    @Autowired
    private UserService userService;
    @Autowired
    private DeptService deptService;

    public UserDTO getUser(String userId) {
        UserDTO user = userService.getUser(userId);
        DeptDTO deptDTO = deptService.getDept(user.getDeptId());
        user.setDeptDTO(deptDTO);
        return user;
    }

    public List<UserDTO> getUserList(String userId) {
        return userService.getUserList(userId);
    }

    public List<UserDTO> getUserList(UserParamDTO userParamDTO) {
        return userService.getUserList(userParamDTO);
    }

    public String getEmployeeName(String userIds) {
        return userService.getEmployeeName(userIds);
    }

    public String CreateUser(CreateUserDTO createUserDTO) {
        return userService.CreateUser(createUserDTO);
    }

    public PageResult<UserDTO> findUserList(UserPageDTO userPageDTO) {
        return userService.findUserList(userPageDTO);
    }

    public Integer updateUser(List<UpdateUserDTO> updateUserDTOList) {
        return userService.updateUser(updateUserDTOList);
    }

    public Integer updateProperty(List<UpdatePropertyDTO> updatePropertyDTOList) {
        return userService.updateProperty(updatePropertyDTOList);
    }

    public UserDTO createUserIfAbsent(CreateUserDTO createUserDTO) {
        return userService.createUserIfAbsent(createUserDTO);
    }
}
